package com.msb.filterandlistrer.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** 拦截器配置类
 * @author LiuShanshan
 * @version V1.0
 * @Description
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer{
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器
        InterceptorRegistration registration = registry.addInterceptor(new InterceptorDemo1());
        // 所有路径被拦截(被拦截，就会经过拦截器里面的方法)
        registration.addPathPatterns("/**");
        System.out.println("========================拦截器启动=======================");
        // 添加白名单（不会经过拦截器）
        registration.excludePathPatterns("你的登陆路径",            //登录
                "/**/*.html",            //html静态资源
                "/**/*.js",              //js静态资源
                "/**/*.css",             //css静态资源
                "/**/*.woff",
                "/**/*.ttf");
    }
}
